package smartvillage.mapper;

import org.apache.ibatis.annotations.*;
import smartvillage.pojo.Livestock;

import java.util.List;

@Mapper
public interface LivestockMapper {
    //增加某村户的家畜
    @Insert("insert into smartvillage.livestock_tb values (null, #{type}, #{number}, #{household}, #{img})")
    void addLivestock(Livestock livestock);

    //删除某村户的家畜
    @Delete("delete from smartvillage.livestock_tb where id = #{id}")
    void deleteLivestock(Integer id);

    //根据村户id查询旗下所有家畜
    @Select("select * from smartvillage.livestock_tb where household= #{id}")
    List<Livestock> getLivestockByHousehold(Integer id);

    //根据家畜id查询他的全部信息
    @Select("select * from smartvillage.livestock_tb where id = #{id}")
    Livestock getLivestockById(Integer id);

    //更新家畜信息
    @Update("update smartvillage.livestock_tb set type = #{type}, number = #{number}, img = #{img} where id = #{id}")
    void updateLivestockLivestock(Livestock livestock);
}
